package org.liulinlin.sejw.db;

import java.sql.*;

/**
 * 询价单
 * @author kodylau
 *
 */
public class QueryPriceForm { //extends DataAccessServiceImpl {
	private int id;
	private java.sql.Date time;
	private String timeString;
	private Customer customer;
	private Goods goods;
	private String shipName;
	private ShipSchedule shipSchedule;
	private String start;
	private String end;
	private String loc;
	private boolean landTransport;
	private boolean declare;
	private boolean order;
	private String comment;
	private boolean proceed;
	
	public QueryPriceForm() {
		
	}
	public QueryPriceForm(int id) {
		DBConnectionManager connMgr = DBConnectionManager.getInstance();
		Connection con = connMgr.getConnection("shipping_export");
		if (con == null) {
			System.out.println("不能获得数据库连接");
			return;
		}
		
		try {
			Statement stmt = con.createStatement();
			String sql = "select * from PriceQueryForm where PQF_ID = '" + id + "'";
			ResultSet rs = stmt.executeQuery(sql);
		
			rs.next();
			this.id = id;
			time = rs.getDate("PQF_Time");
			timeString = time.toString();			
			customer = new Customer(rs.getString("Customer_ID"));
			goods = new Goods(rs.getString("Goods_ID"));
			shipName = rs.getString("PQF_ShipName");
			if (rs.getString("Scd_ID") != null) {
				shipSchedule = new ShipSchedule(rs.getString("Scd_ID"));
			}
			start = rs.getString("PQF_Start");
			end = rs.getString("PQF_End");
			loc = rs.getString("PQF_Loc");
			landTransport = rs.getBoolean("PQF_LandTransport");
			declare = rs.getBoolean("PQF_Declare");
			order = rs.getBoolean("PQF_Order");
			comment = rs.getString("PQF_Comment");
			proceed = rs.getBoolean("PQF_Proceed");
			
			rs.close();
			stmt.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		connMgr.freeConnection("shipping_export", con);
		connMgr.release();
	}
	
	public void setID(int id) {
		this.id = id;
	}
	public void setTime(java.sql.Date time) {
		this.time = time;
	}
	public void setTimeString(java.sql.Date time) {
		this.timeString = time.toString();
	}
	public void setCustomer(Customer customer) {
		this.customer = customer;
	}
	public void setGoods(Goods goods) {
		this.goods = goods;
	}
	public void setShipName(String shipName) {
		this.shipName = shipName;
	}
	public void setShipSchedule(ShipSchedule shipSchedule) {
		this.shipSchedule = shipSchedule;
	}
	public void setStart(String start) {
		this.start = start;
	}
	public void setEnd(String end) {
		this.end = end;
	}
	public void setLoc(String loc) {
		this.loc = loc;
	}
	public void setLandTransport(boolean landTransport) {
		this.landTransport = landTransport;
	}
	public void setDeclare(boolean declare) {
		this.declare = declare;
	}
	public void setOrder(boolean order) {
		this.order = order;
	}
	public void setComment(String comment) {
		this.comment = comment;
	}
	public void setProceed(boolean proceed) {
		this.proceed = proceed;
	}
	
	public int getID() {
		return id;
	}
	public java.sql.Date getTime() {
		return time;
	}
	public String getTimeString() {
		return timeString;
	}
	public Customer getCustomer() {
		return customer;
	}
	public Goods getGoods() {
		return goods;
	}
	public String getShipName() {
		return shipName;
	}
	public ShipSchedule getShipSchedule() {
		return shipSchedule;
	}
	public String getStart() {
		return start;
	}
	public String getEnd() {
		return end;
	}
	public String getLoc() {
		return loc;
	}
	public boolean getLandTransport() {
		return landTransport;
	}
	public boolean getDeclare() {
		return declare;
	}
	public boolean getOrder() {
		return order;
	}
	public String getComment() {
		return comment;
	}
	public boolean getProceed() {
		return proceed;
	}
}
